/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package com.cn.xiaonuo.tcrfinance.sysmgmt.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.xiaonuo.core.factory.PageFactory;
import com.cn.xiaonuo.core.pojo.page.PageResult;
import com.cn.xiaonuo.tcrfinance.sysmgmt.entity.SysLogHpcEntity;
import com.cn.xiaonuo.tcrfinance.sysmgmt.mapper.SysLogHpcMapper;
import com.cn.xiaonuo.tcrfinance.sysmgmt.param.SysLogHpcParam;
import com.cn.xiaonuo.tcrfinance.sysmgmt.service.SysLogHpcService;
import org.springframework.stereotype.Service;


@Service
public class SysLogHpcServiceImpl extends ServiceImpl<SysLogHpcMapper, SysLogHpcEntity> implements SysLogHpcService {

    @Override
    public PageResult<SysLogHpcEntity> queryPage(SysLogHpcParam sysLogParam) {
        QueryWrapper<SysLogHpcEntity> queryWrapper = new QueryWrapper<>();
        if (ObjectUtil.isNotNull(sysLogParam)) {

            // 根据唯一标识 查询
            if (ObjectUtil.isNotEmpty(sysLogParam.getParamKey())) {
               // queryWrapper.lambda().like(SysLogHpcEntity::getOperation, sysLogParam.getParamKey());
                queryWrapper.lambda().like(SysLogHpcEntity::getUsername, sysLogParam.getParamKey());
            }
        }
        queryWrapper.lambda().orderByDesc(SysLogHpcEntity::getCreateDate);
        return new PageResult<>(this.page(PageFactory.defaultPage(), queryWrapper));
    }
}
